package initialize

import (
	"fmt"
	"goods_srv/global"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"sync"
)

var (
	once sync.Once
	err  error
)

func InitMySQL() {
	dsn := "root:123456@tcp(127.0.0.1:3306)/take?charset=utf8mb4&parseTime=True&loc=Local"
	global.Db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		panic(err)
		return
	}

	fmt.Println("mysql链接成功")
}
